package com.songlanyun.modules.protocol.controller.admin;

import com.songlanyun.common.annotation.SysLog;
import com.songlanyun.common.utils.PageUtils;
import com.songlanyun.common.utils.R;
import com.songlanyun.modules.protocol.entity.SysProtocolEntity;
import com.songlanyun.modules.protocol.service.SysProtocolService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Arrays;
import java.util.Map;

//import org.apache.shiro.authz.annotation.RequiresPermissions;


/**
 * 会员注册和商家申请协议
 *
 * @author lubo
 * @email sunlightcs@gmail.com
 * @date 2021-02-01 15:37:15
 */
@RestController
@RequestMapping("admin/protocol")
public class SysProtocolAdminController {
    @Autowired
    private SysProtocolService sysProtocolService;


    /**
     * 设置会员注册协议
     */
    @SysLog("设置会员注册协议")
    @PutMapping("/set-user-protocol")
    //@RequiresPermissions("protocol:sysprotocol:save")
    public R setUserProtocol(@RequestBody SysProtocolEntity sysProtocol){
        sysProtocolService.setUserProtocol(sysProtocol);
        return R.ok();
    }


    /**
     * 设置商家注册协议
     */
    @SysLog("设置商家注册协议")
    @PutMapping("/set-shop-protocol")
    //@RequiresPermissions("protocol:sysprotocol:save")
    public R setShopProtocol(@RequestBody SysProtocolEntity sysProtocol){
        sysProtocolService.setShopProtocol(sysProtocol);
        return R.ok();
    }


    /**
     * 获取平台协议
     */
    @RequestMapping("/info")
    //@RequiresPermissions("protocol:sysprotocol:info")
    public R info(){
		SysProtocolEntity sysProtocol = sysProtocolService.get();

        return R.ok().put("data", sysProtocol);
    }


}
